//
//  ZallFilterView.h
//  ZallDemo
//
//  Created by so on 16/6/20.
//  Copyright © 2016年 so. All rights reserved.
//

#import "ZallBaseView.h"
#import "ZallCheckBoxCell.h"
#import "ZallRowItem.h"

NS_ASSUME_NONNULL_BEGIN

@class ZallFilterItem;
@protocol ZallFilterViewDelegate;

extern NSTimeInterval const ZallFilterAnimationDuration;


@interface ZallFilterView : ZallBaseView <UITableViewDataSource, UITableViewDelegate> {
    __weak id <ZallFilterViewDelegate> _delegate;
}

/**
 *  @brief  回调代理，可为空
 */
@property (weak, nonatomic, nullable) id <ZallFilterViewDelegate> delegate;

/**
 *  @brief  初始化方法，components为列数量，items不可为空
 */
- (instancetype)initWithFrame:(CGRect)frame items:(NSArray <__kindof ZallFilterItem *> * _Nonnull)items;

/**
 *  @brief  显示在view上，如果view为nil则自动设置为keywindow，默认为从顶部出来
 */
- (void)showInView:(UIView * _Nullable)view;
- (void)showInView:(UIView * _Nullable)view fromRect:(CGRect)fromRect animated:(BOOL)animated;
- (void)showInView:(UIView * _Nullable)view fromRect:(CGRect)fromRect toRect:(CGRect)toRect animated:(BOOL)animated;

/**
 *  @brief  使消失的方法，默认有动画，默认为从底部消失
 */
- (void)dismiss;
- (void)dismissAnimated:(BOOL)animated;

@end



@interface ZallFilterView (PickSubviews)

/**
 *  @brief  单元格高度，default is 40.0f
 */
@property (nonatomic) CGFloat rowHeight;

/**
 *  @brief  系统表格
 */
@property (readonly, nonnull) UITableView *tableView;

@end



@protocol ZallFilterViewDelegate <NSObject>
@optional
- (BOOL)filterView:(ZallFilterView *)filterView shouldSelectRowAtIndex:(NSInteger)index;
- (void)filterView:(ZallFilterView *)filterView didSelectedRowAtIndex:(NSInteger)index;
@end



@interface ZallFilterViewCell : ZallCheckBoxCell
@property (copy, nonatomic, nonnull) ZallFilterItem *item;
@end



@interface ZallFilterItem : ZallRowItem
/**
 *  @brief  选择框大小（默认0x0）
 */
@property (assign, nonatomic) CGSize checkBoxSize;

+ (instancetype)itemWithAttributedText:(NSAttributedString *)attributedText;
+ (instancetype)itemWithAttributedText:(NSAttributedString *)attributedText selected:(BOOL)selected;
@end

NS_ASSUME_NONNULL_END
